<?php


namespace app\api\controller;

use app\admin\model\HistoryPeripheral;
use think\Request;

class CompanyPeripheral extends Base
{
    public function getCompanyPeripheralList(Request $request){
        $res = [];
        $data = $request->post();
        if(!isset($data['type'])){
            $res['status'] = 400;
            echo json_encode($res);die;
        }

        $historyPeripheral = new HistoryPeripheral();
        $where['type'] = $data['type'];
        $where['status'] = 1;
        $list = $historyPeripheral->getAll($where);

        if($list == null){
            $res['data']['code'] = 0;
            $res['data']['msg'] = '获取失败';
        }else{
            $res['data']['code'] = 1;
            $res['data']['msg'] = '获取成功';
            $res['data']['list'] = $list;
        }


        $res['status'] = 200;
        echo json_encode($res);
    }

    public function getCompanyDetail(Request $request){
        $res = [];
        $data = $request->post();
        if(!isset($data['id'])){
            $res['status'] = 400;
            echo json_encode($res);die;
        }

        $historyPeripheral = new HistoryPeripheral();
        $where['id'] = $data['id'];
        $where['status'] = 1;
        $list = $historyPeripheral->getOne($where);
        if($list == null){
            $res['data']['code'] = 0;
            $res['data']['msg'] = '获取失败';
        }else{
            $res['data']['code'] = 1;
            $res['data']['msg'] = '获取成功';
            $res['data']['list'] = $list;
        }

        $res['status'] = 200;
        echo json_encode($res);
    }
}